<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <script type="text/javascript" src="./Public/JQuery/jquery-1.4.4.js"></script>
        <script type="text/javascript" src="./Public/JQuery/ui/jquery.ui.core.js"></script>
        <script type="text/javascript" src="./Public/JQuery/ui/jquery.effects.core.js"></script>
        <script type="text/javascript" src="./Public/JQuery/ui/jquery.ui.widget.js"></script>
        <script type="text/javascript" src="./Public/JQuery/ui/jquery.ui.datepicker.js"></script>
        <script type="text/javascript" src="./Public/JQuery/ui/jquery.ui.button.js"></script>
        <script type="text/javascript" src="./Public/js/html.js"></script>
        <link rel="stylesheet" type="text/css" href="./Public/JQuery/themes/base/jquery.ui.all.css">
        <link rel="stylesheet" type="text/css" href="./Public/css/grid.css">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript">
            //JQuery
            $(document).ready(function(){
                $("#history").buttonset().click(function(){
                    if($("#radio4").attr("checked"))
                    {
                        $("#result1").hide();
                        $("#result").show();
                        $("#result").find("#Template").hide();
                    }
                    else
                    {
                        $("#result").hide();
                        $("#result1").show();
                        $("#result1").find("#Template1").hide();
                    }
                });
                $("#result1").hide();
                $("#Template").hide();
                var dates = $( "#from, #to" ).datepicker({
                    defaultDate: "+1w",
                    changeMonth: true,
                    dateFormat: "yy-mm-dd",
                    onSelect: function( selectedDate ) {
                        var option = this.id == "from" ? "minDate" : "maxDate",
                        instance = $( this ).data( "datepicker" ),
                        date = $.datepicker.parseDate(
                        instance.settings.dateFormat ||
                            $.datepicker._defaults.dateFormat,
                        selectedDate, instance.settings );
                        dates.not( this ).datepicker( "option", option, date );
                    }});
                $("form").find("input:button").button().click(function(){
                    var forpost = $("#datepick").serialize();
                    $.post("/TDX/index.php?s=/Fund/jsonGetRecords", forpost, function(data){
                        if($("#radio4").attr("checked"))
                        {
                            $("#Template").show();
			    $("#include").
                            var t = $("#Template").clone();
                            $("#result").find("table").find("tr:gt(0)").remove();
                            $("#result").find("table").append(t);
                            data = data.data;
                            for(var i = 0; i < data.length; i++)
                            {
                                var tmp = $("#Template").clone();
                                if(parseFloat(data[i].totalvalue) < 0)
                                    tmp.find("#tType").text("赎回");
                                else
                                    tmp.find("#tType").text("申购");
                                tmp.find("#tTime").text(data[i].rtime);
                                tmp.find("#tMoney").text(dealFloat(data[i].totalvalue));
                                tmp.find("#tParts").text(dealFloat(data[i].parts));
                                var t = parseFloat(data[i].totalvalue)/parseFloat(data[i].parts);
                                tmp.find("#tNet").text(dealFloat(t));
                                $("#result").find("table").append(tmp);
                            }
                            $("#Template").hide();
                            $("#result").find("tr:even").css('background-color', 'rgb(153,204,255)');
                            $("#result").find("tr").find("th").css('padding', '4px');
                            $("#result").find("td").css("padding", "3px 0px");
                            $("#result").find("td").css("font-size", "12px");
                            $("#result").find("td").css("font-family", "Microsoft YaHei");
                            $("#result").find("tr").css('text-align', 'center');
                            $("#result").find("tr:first").css('background-color', 'rgb(132,132,132)');
                            $("#result").find("tr:first").css('font-family', 'SimHei');
                            $("#result").find("tr:first").css('font-size', '20px');
                        }
                        else
                        {
                            $("#Template1").show();
                            var t = $("#Template1").clone();
                            $("#result1").find("table").find("tr:gt(0)").remove();
                            $("#result1").find("table").append(t);
                            data = data.data;
                            for(var i = 0; i < data.length; i++)
                            {
                                var tmp = $("#Template1").clone();
                                if(parseFloat(data[i].value) != 0)
                                {
                                    if(parseFloat(data[i].totalvalue) > 0)
                                        tmp.find("#t1Type").text("投资收入");
                                    else
                                        tmp.find("#t1Type").text("投资支出");
                                }
                                else
                                {
                                    if(parseFloat(data[i].totalvalue) > 0)
                                        tmp.find("#t1Type").text("财务收入");
                                    else
                                        tmp.find("#t1Type").text("财务支出");
                                }
                                tmp.find("#t1Time").text(data[i].rtime);
                                tmp.find("#t1Money").text(dealFloat(data[i].totalvalue));
                                var before = parseFloat(data[i].htotal);
                                var after = parseFloat(data[i].htotal) + parseFloat(data[i].totalvalue);
                                var amount = parseFloat(data[i].hparts);
                                tmp.find("#t1Before").text(dealFloat(before/amount));
                                tmp.find("#t1After").text(dealFloat(after/amount));
                                tmp.find("#t1Description").text(data[i].description);
                                $("#result1").find("table").append(tmp);
                            }
                            $("#Template1").hide();
                            $("#result1").find("tr:even").css('background-color', 'rgb(153,204,255)');
                            $("#result1").find("tr").find("th").css('padding', '4px');
                            $("#result1").find("td").css("padding", "3px 0px");
                            $("#result1").find("td").css("font-size", "12px");
                            $("#result1").find("td").css("font-family", "Microsoft YaHei");
                            $("#result1").find("tr").css('text-align', 'center');
                            $("#result1").find("tr:first").css('background-color', 'rgb(132,132,132)');
                            $("#result1").find("tr:first").css('font-family', 'SimHei');
                            $("#result1").find("tr:first").css('font-size', '20px');
                        }
                    }, "json");
                });
            });
        });
        </script>
        <style type="text/css">

        </style>
        <title>{$title}</title>
    </head>
    <body>
        <div>
            <form id="datepick" name="datepick" style="font-size:14px">
                <label for="from">From</label><input type="text" id="from" name="from">
                <label for="to">to</label><input type="text" id="to" name="to"><input type="button" value="查询">
                <div id="history">
                    <input type="radio" id="radio4" value="0" name="history" checked='checked'><label for="radio4">我的申购记录</label>
                    <input type="radio" id="radio5" value="1" name="history"><label for="radio5">净值变化历史</label>
                </div>
            </form>
            <div class="titlecolumn grid_6" id="result">
                <p class="smalltitle">查询结果</p>
                <table style="text-align:center">
                    <tr>
                        <th style="width:50px">类型</th>
                        <th style="width:130px">操作时间</th>
                        <th style="width:60px">金额</th>
                        <th style="width:60px">份额</th>
                        <th style="width:100px">交易净值</th>
                    </tr>
                    <tr id="Template">
                        <td id="tType" style="width:50px">类型</td>
                        <td id="tTime" style="width:130px">操作时间</td>
                        <td id="tMoney" style="width:60px">金额</td>
                        <td id="tParts" style="width:60px">份额</td>
                        <td id="tNet" style="width:100px">交易净值</td>
                    </tr>
                </table>
            </div>
            <div class="titlecolumn grid_7" id="result1">
                <p class="smalltitle">查询结果</p>
                <table style="text-align:center">
                    <tr>
                        <th style="width:60px">类型</th>
                        <th style="width:130px">操作时间</th>
                        <th style="width:60px">金额</th>
                        <th style="width:100px">交易前净值</th>
                        <th style="width:100px">交易后净值</th>
                        <th style="width:100px">交易描述</th>
                    </tr>
                    <tr id="Template1">
                        <td id="t1Type" style="width:60px">类型</td>
                        <td id="t1Time" style="width:130px">操作时间</td>
                        <td id="t1Money" style="width:60px">金额</td>
                        <td id="t1Before" style="width:100px">交易前净值</td>
                        <td id="t1After" style="width:100px">交易后净值</td>
                        <td id="t1Description" style="width:100px">交易描述</td>
                    </tr>
                </table>
            </div>
        </div>
    </body>
</html>